<?php

	 $db_host = 'localhost';
	 $db_user = 'function';
	 $db_pwd = 'w9ak4X1l0Y';

	 $database = 'function_a5110060';
	 $table = 'Location_Master';

	$con = mysql_connect($db_host, $db_user, $db_pwd);
	if (!$con)
	die("Can't connect to database");
	mysql_select_db($database,$con);

	$location = $_REQUEST['location'];
	$locationId = $_REQUEST['locationId'];
	//echo("Locaiton id : ".$locationId);
	$currentDate = date("Y-m-d");
	
	if (empty($locationId)) {
		$sql="INSERT INTO {$table} (master_location_name,created_date,modified_date) VALUES ('".$location."','".$currentDate."','".$currentDate."')";
		//echo("Sql :".$sql);
		$result=mysql_query($sql);
	} else {
		$sql="UPDATE {$table} SET master_location_name='".$location. "',modified_date='".$currentDate."' where master_location_id=".$locationId;
		//echo("Sql :".$sql);
		$result=mysql_query($sql);
		//echo("$result :".$result);
	}
	header("Location: ../location.php");
?> 